import requests,pytest

# class MultiThreadTest():
#     def __init__(self):
#         # 用session保持会话
#         self.session = requests.session()
#
#     # 打开首页
#     def open_home(self):
#         self.session.get("http://localhost:8080/woniusales")
#
#     # 登录
#     def do_login(self):
#         data = {'username':'admin','password':'admin123','verifycode':'0000'}
#         url = "http://localhost:8080/woniusales/user/login"
#         r_login = self.session.post(url,data)
#         print(r_login.text)
#
#     # 会员查询
#     def do_select(self):
#         data = {'customerphone':'987654321','page':'1'}
#         url = "http://localhost:8080/woniusales/customer/search"
#         r_select = self.session.post(url,data)
#         print(r_select.text)
#
# if __name__ == '__main__':__main__
#     mt = MultiThreadTest()
#     # mt.open_home()
#     mt.do_login()
#     mt.do_select()



s = requests.session()
def info(s):
    # s = 'userName=wntf007&userPass=woniu123&checkcode=0000'
    info=s.replace("&",'","')
    info=info.replace("=",'":"')
    info='{"'+info+'"}'
    return eval(info)

def test_login():
    url = 'http://localhost:8080/woniuboss/login/userLogin'
    # data = {'userName':'wntf007','userPass':'woniu123','checkcode':'0000'}
    data = info('userName=wntf007&userPass=woniu123&checkcode=0000')
    r = s.post(url,data)
    # print(r.text)
    assert r.text == 'success'

def test_home():
    url = 'http://localhost:8080/woniuboss/main'
    r = requests.get(url)
    # print(r.text)


def test_queryuser():
    url = 'http://localhost:8080/woniuboss/user/queryUser'
    data = info('pageSize=10&pageIndex=1&userName=wntf007&empName=')
    r = s.post(url,data)
    print(r.json())
    # assert r.text

if __name__ == '__main__':
    # pytest.main(['-v','-s',__file__])
    test_login()
    test_queryuser()



# url1 = 'http://localhost:8080/woniuboss/login/userLogin'
# data = {'userName':'wntf007','userPass':'woniu123','checkcode':'0000'}
#
# r=s.post(url1,data)
# print(r.text)
# url = 'http://localhost:8080/woniuboss/user/queryUser'
# data = info('pageSize=10&pageIndex=1&userName=wntf007&empName=')
# r1 = s.post(url,data)
# print(r1.json())


















